From 2a94483642181a214bc19c2891fd8f070ed0060a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 1 Aug 2014 08:52:51 -0700 Subject: [PATCH] Ensure manifest paths are absolute paths Closes #299 --- src/cargo/util/important_paths.rs | 14 +++++++------- tests/test_cargo_compile.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/cargo/util/important_paths.rs b/src/cargo/util/important_paths.rs index 614bfd307..b7604d51c 100644 --- a/src/cargo/util/important_paths.rs +++ b/src/cargo/util/important_paths.rs @@ -1,4 +1,4 @@ -use std::os::{getcwd}; +use std::os; use util::{CargoResult, CliError, CliResult, human}; /// Iteratively search for `file` in `pwd` and its parents, returning @@ -34,12 +34,12 @@ pub fn find_project_manifest(pwd: &Path, file: &str) -> CargoResult { pub fn find_root_manifest_for_cwd(manifest_path: Option) -> CliResult { match manifest_path { Some(path) => Ok(Path::new(path)), - None => match find_project_manifest(&getcwd(), "Cargo.toml") { - Ok(x) => Ok(x), - Err(_) => Err(CliError::new("Could not find Cargo.toml in this \ - directory or any parent directory", 102)) - } - } + None => match find_project_manifest(&os::getcwd(), "Cargo.toml") { + Ok(x) => Ok(x), + Err(_) => Err(CliError::new("Could not find Cargo.toml in this \ + directory or any parent directory", 102)) + } + }.map(|path| os::make_absolute(&path)) } /// Return the path to the `file` in `pwd`, if it exists. diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index 49e45b96f..b5bf1173a 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -25,6 +25,18 @@ test!(cargo_compile_simple { execs().with_stdout("i am foo\n")); }) +test!(cargo_compile_manifest_path { + let p = project("foo") + .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) + .file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice()); + + assert_that(p.cargo_process("cargo-build") + .arg("--manifest-path").arg("foo/Cargo.toml") + .cwd(p.root().dir_path()), + execs().with_status(0)); + assert_that(&p.bin("foo"), existing_file()); +}) + test!(cargo_compile_with_invalid_manifest { let p = project("foo") .file("Cargo.toml", ""); -- 2.30.2